home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9110.ZIP / ACTOR.ZIP / EXTSOURC.TXT
Text File  |  1991-07-15  |  26KB  |  1,012 lines

  1.  
  2.  
  3. /* EXTEND.LOD - Actor development extensions load file
  4.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  5.  *    Steve Hatchett          14352 Mussey Grade Rd.
  6.  *    CIS: 70304,1423         Ramona, CA 92065
  7.  * Use this file to load the development environment
  8.  * extensions for use with the Actor programming
  9.  * language.
  10.  *     load("extend.lod");
  11.  *     load();
  12.  */
  13. #define MAXSOURCENEST 5;      /* max directory nesting */
  14. Actor[#Programmer] := "   ";  /* set this in workspace */
  15. Actor[#StampText]  := "Stamp";/* time stamp header.  Another
  16.                                * useful stamp header would be
  17.                                * "Copyright (C) 1991 XYZ, Inc."*/
  18. LoadFiles :=
  19. {
  20. /* Your path may be different. */
  21.   load(new(SourceFile),"c:\actor\general\classes\string.clx");
  22.   load(#("classes\extsource.cls"
  23.          "c:\actor\general\classes\symbol.clx"));
  24.  
  25. /* The minimum code necessary to navigate the directory
  26.  * hierarchy has now been loaded, paths are no longer needed.
  27.  */
  28.   do(#(Behavior Browser ClassDialog ClVarDialog  Function
  29.        SourceFile System ToolWind WorkEdit), {using(cl)
  30.     loadExtensions(cl);
  31.   });
  32. }!!
  33.  
  34. -----------------------------------------------------------------
  35.  
  36. /* EXTSOURCE.CLS - Actor development extensions
  37.  
  38.  Copyright (C) 1991  Steve Hatchett.  All rights reserved.
  39.  Provides access to class source code.  Allows the source code for a class
  40.  to be contained in more than one file ordered hierarchically by directory
  41.  structure.  There is one .cls file containing the actual class definition.  
  42.  Additional .clx files may be exist at lower levels of the hierarchy.  They 
  43.  can contain methods and class initialization code. */!!
  44.  
  45. inherit(Object, #ExtSourceFiler,
  46.         #(clName      /* Name of class being handled. */
  47.           ownsClass   /* True if the .cls file for class is
  48.                          in this session's directory. */
  49.           fileNames   /* Source code file names with paths. */
  50.           ownsLast    /* True if we owned the last method
  51.                          we read. */), 2, nil)!!
  52.  
  53. now(class(ExtSourceFiler))!!
  54.  
  55. /* Return a new  ExtSourceFiler, initialized to handle
  56.    source code for the class whose name Symbol was
  57.    given.
  58.  */
  59. Def openClass(self className)
  60. {
  61.   ^init(new(self),className);
  62. } !!
  63.  
  64. now(ExtSourceFiler)!!
  65.  
  66. /* Load class extension files (.clx) for the class, 
  67.    but don't load the class file (.cls).  This is
  68.    useful for loading extensions to the standard
  69.    Actor classes.  Looks for all files in CLASSES
  70.    subdirectories.
  71.  */
  72. Def loadExtensions(self | work fNames fnm)
  73. {
  74.   work := loadString(332);
  75.   if size(fileNames) > 0
  76.      cand subString(first(fileNames),0,size(work))=work
  77.     fileNames[0] := loadString(331) + getFileName(self);
  78.     if not(exists(File,fileNames[0],0))
  79.       removeFirst(fileNames);
  80.     endif;
  81.   endif;
  82.   if size(fileNames) > 0
  83.     fNames := copy(fileNames);
  84.     fnm := last(fNames);
  85.     if fnm[size(fnm)-1] == 's'
  86.       pop(fNames);       /* removes the .cls file */
  87.     endif;
  88.     ^do(reverse(fNames), {using(fnm)
  89.        load(new(SourceFile),fnm);
  90.      });
  91.   endif;
  92.   ^nil;
  93. }!!
  94.  
  95. /* Recompile the class by loading all its source code.
  96.    Looks in WORK for own source file if class is dirty.
  97.  */
  98. Def recompile(self)
  99. {
  100.   ^do(reverse(fileNames), {using(fnm)
  101.      load(new(SourceFile),fnm);
  102.    });
  103. }!!
  104.  
  105. /* Return an open SourceFile with given file name
  106.    (which should include path).
  107.  */
  108. Def openSourceFile(self fName | sFile)
  109. {
  110.   sFile := new(SourceFile);
  111.   setName(sFile,fName);
  112.   if not(open(sFile,0))
  113.     errorBox(loadString(311), clName
  114.     + loadString(312)+fName+".");
  115.     ^nil;
  116.   endif;
  117.   ^sFile;
  118. }!!
  119.  
  120. /* If no source file exists for the class at the 
  121.    directory level of this actor session, then create
  122.    an extension file in WORK, and mark the class as
  123.    dirty.
  124.  */
  125. Def mustHaveOwn(self | sFile)
  126. {
  127.   if size(fileNames) == 0
  128.      cor first(fileNames)[0] == '.'
  129.     add(DirtyClasses,clName);
  130.     insert(fileNames,loadString(332)
  131.                   +subString(clName,0,8)+".clx",0);
  132.     makeClassExtFile(new(SourceFile),self);
  133.   endif;
  134. }!!
  135.  
  136. /* Replace the the fSym method text with methtext, or
  137.    add the method text if it wasn't already in the
  138.    source file.  The mode determines whether the
  139.    method is a class or object method. These changes
  140.    will only be made in the source file owned by this
  141.    actor session. Returns nil if not successful.
  142.  */
  143. Def saveMethText(self methtext fSym mode | rFile wFile)
  144. {
  145.   mustHaveOwn(self);
  146.   if (rFile := openClass(SourceFile,self))
  147.     wFile := saveMethText(rFile,methtext,fSym,mode);
  148.     reName(wFile,(fileNames[0] := condDelCFile(rFile,self)));
  149.   endif;
  150.   ^rFile;
  151. }!!
  152.  
  153. /* Replace the the class initialization code, with
  154.    the given code.  The change will only be made in
  155.    the source file owned by this actor session.
  156.    Returns nil if not successful.
  157.  */
  158. Def replaceClassInit(self text | rFile wFile)
  159. {
  160.   mustHaveOwn(self);
  161.   if (rFile := openClass(SourceFile,self))
  162.     wFile := replaceClassInit(rFile,text);
  163.     reName(wFile,(fileNames[0] := condDelCFile(rFile,self)));
  164.     close(rFile);
  165.   endif;
  166.   ^rFile;
  167. }!!
  168.  
  169. /* Return the class init code for this class as a
  170.    TextCollection. */
  171. Def readClassInit(self | rFile text)
  172. {
  173. /* look through source files until some
  174.  * class initialization text is found.
  175.  */
  176.   ownsLast := false;
  177.   do(fileNames,{using(fnm)
  178.     if (rFile := openSourceFile(self,fnm))
  179.       text := readClassInit(rFile);
  180.       close(rFile);
  181.       if size(text) > 0
  182.         ownsLast := (fnm[0] <> '.');
  183.         ^text;
  184.       endif;
  185.     endif;
  186.   });
  187.   ^new(TextCollection,5);
  188. }!!
  189.  
  190. /* Remove the fSym method text if it is found in
  191.    the source file owned by this actor session.
  192.    The mode determines whether the method is a
  193.    class or object method.  Returns nil if not
  194.    successful or if the method was not in the
  195.    owned source file.
  196.  */
  197. Def removeMethod(self fSym mode | rFile wFile)
  198. {
  199.   if size(fileNames) > 0
  200.      cand first(fileNames)[0] <> '.'
  201.      cand (rFile := openClass(SourceFile,self))
  202.     if wFile := replaceMethod(rFile,nil,fSym,mode)
  203.       reName(wFile,(fileNames[0] := condDelCFile(rFile,self)));
  204.     endif;
  205.     close(rFile);
  206.   endif;
  207.   ^wFile;
  208. }!!
  209.  
  210. /* Load the class by loading all its source code.
  211.    Looks in CLASSES for all source files.
  212.  */
  213. Def load(self | work)
  214. {
  215.   work := loadString(332);
  216.   if size(fileNames) > 0
  217.      cand subString(first(fileNames),0,size(work))=work
  218.     fileNames[0] := loadString(331) + getFileName(self);
  219.     if not(exists(File,fileNames[0],0))
  220.       removeFirst(fileNames);
  221.     endif;
  222.   endif; 
  223.   ^do(reverse(fileNames), {using(fnm)
  224.      load(new(SourceFile),fnm);
  225.    });
  226. }
  227. !!
  228.  
  229. /* Return true if the last method read using
  230.    loadMethText was from a source file at the
  231.    directory level of this actor session.
  232.  */
  233. Def ownsLast(self)
  234. {
  235.   ^ownsLast;
  236. }!!
  237.  
  238. /* Initialize a new ExtSourceFiler. 
  239.  */
  240. Def init(self nm | metaNm)
  241. {
  242.   if class(nm) <> Symbol
  243.     nm := name(nm);
  244.   endif;
  245.   if (metaNm := isMetaName(nm))
  246.     clName := name(value(metaNm));
  247.   else
  248.     clName := nm;
  249.   endif;
  250.   getFileNames(self);
  251. }!!
  252.  
  253. /* Return true if the .cls file for the class this
  254.    filer is handling exists at the directory level
  255.    of this actor session.
  256.  */
  257. Def ownsClass(self)
  258. {
  259.   ^ownsClass;
  260. }!!
  261.  
  262. /* Return the text of aMethod.  Note accordingly if
  263.    the source code is missing. The mode indicates
  264.    type of method, either class (BR_CMETH) or
  265.    object (BR_OMETH).  Looks through all the source
  266.    files for the class.
  267.  */
  268. Def loadMethText(self aMethod mode | text rFile)
  269. {
  270. /* look through source files until the
  271.  * text for the given method is found.
  272.  */
  273.   ownsLast := false;
  274.   rFile := new(SourceFile);
  275.   do(fileNames,{using(fnm)
  276.     if not(rFile := openSourceFile(self,fnm))
  277.       errorBox(loadString(311), clName
  278.                +loadString(312)+fnm+".");
  279.     else
  280.       text := findMethod(rFile,aMethod,mode);
  281.       close(rFile);
  282.       if text
  283.         ownsLast := (fnm[0] <> '.');
  284.         ^leftJustify(text[0]);
  285.       endif;
  286.     endif;
  287.   });
  288.   ^aMethod + loadString(310);
  289. }!!
  290.  
  291. /* Return the class's name the way Behavior
  292.    would do it.
  293.  */
  294. Def name(self)
  295. {
  296.   ^clName;
  297. }!!
  298.  
  299. /* Return the class's filename the way Behavior
  300.    would do it.
  301.  */
  302. Def getFileName(self | dir)
  303. {
  304. /* return name + ext */
  305.   ^subString(clName,0,8)
  306.    + if ownsClass
  307.      ".cls" else ".clx" endif;
  308. }!!
  309.  
  310. /* Get the names of the files containing this
  311.    class' source code.
  312.  */
  313. Def getFileNames(self | dir fRoot base)
  314. {
  315.   fileNames := new(OrderedCollection,MAXSOURCENEST);
  316.   dir := loadString(if clName in DirtyClasses
  317.                     332 else 331 endif);
  318.   base := subString(clName,0,8);
  319.   fRoot := dir + base;
  320.   do(MAXSOURCENEST, {using(i | fnm)
  321.  
  322. /* if the original .cls file or a .clx file is
  323.  * found for the class, add it to list if it's
  324.  * above this session's directory.
  325.  */
  326.     if exists(File,(fnm:=fRoot+".cls"),0)
  327.       add(fileNames,fnm);
  328.       if i==0
  329.         ownsClass := true;
  330.       endif;
  331.       ^fileNames;
  332.     endif;
  333.     if exists(File,(fnm:=fRoot+".clx"),0)
  334.       add(fileNames,fnm);
  335.     endif;
  336.     
  337. /* construct the path name of the next higher level. */
  338.     if i==0
  339.       fRoot := "..\classes\"+base;
  340.     else
  341.       fRoot := "..\"+fRoot;
  342.     endif;
  343.   });
  344.   ^fileNames;
  345. }!!
  346.  
  347. /* Return the names of the files containing this
  348.    class' source code (including own source file).
  349.  */
  350. Def fileNames(self)
  351. {
  352.   ^fileNames;
  353. }!!
  354.  
  355. -----------------------------------------------------------------
  356.  
  357. /* BEHAVIOR.CLX - Actor development extensions
  358.  *
  359.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  360.  */!!
  361. now(class(Behavior))!!
  362.  
  363. now(Behavior)!!
  364.  
  365. /* Backup the original class source file by moving it
  366.   to the BACKUP directory.  Then move the source file
  367.   in WORK directory to the CLASSES directory.
  368.   
  369.   swh modified to support extended source files
  370.  */
  371. Def bak_Save(self | name, theFile)
  372. { name := getFileName(self);
  373.  
  374. /* mod to support extended source files */
  375.   if not(exists(File,loadString(332)+name,0))
  376.     name[size(name)-1] := 'x';
  377.   endif;
  378. /* end mod */
  379.  
  380.   theFile := new(File);
  381. ...
  382. }!!
  383.  
  384. /* Return true is the .cls file defining this class
  385.    exists at the directory level of this actor session.
  386.  */
  387. Def isOwnClass(self | dir fileName)
  388. {
  389.   dir := loadString(if name in DirtyClasses
  390.                     332 else 331 endif);
  391.   fileName := subString(name,0,8)+".cls";
  392.   if exists(File,dir+fileName,0)
  393.     ^fileName;
  394.   else
  395.     ^nil;
  396.   endif;
  397. }!!
  398.  
  399. -----------------------------------------------------------------
  400.  
  401. /* BROWSER.CLX - Actor development extensions
  402.  *
  403.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  404.  */!!
  405. now(class(Browser))!!
  406.  
  407. now(Browser)!!
  408.  
  409. /* Setup for editing a newly selected or created
  410.   class.
  411.   
  412.   swh modified to support extended source files
  413.  */
  414. Def initClassEdit(self | class, clsStrNum)
  415. {...
  416.   if selClass
  417.  
  418. /* mod to support extended source files
  419.  * show ownership info in title bar.
  420.  */
  421.     setTitleClass(self);
  422.     if mode == BR_CMETH
  423.       class := class(selClass);
  424.     else
  425.       class := selClass;
  426.     endif;
  427. /* end mod */
  428.  
  429.     loadMethods(self);
  430. ...
  431. }!!
  432.  
  433. /* Let ancestor save the method text, then reset
  434.    the method name in the title bar since ownership
  435.    could have changed.
  436.  */
  437. Def saveMethText(self text fSym | ret)
  438. {
  439.   if fSym cand (ret := saveMethText(self:ancestor,text,fSym))
  440.     setTitleMethod(self,asString(fSym),true);
  441.   endif;
  442.   ^ret;
  443. }!!
  444.  
  445. /* Set the title bar to the selected class,
  446.    placing brackets around unowned class.
  447.  */
  448. Def setTitleClass(self | classNm text)
  449. {
  450.   text := name(class(self));
  451.   if selClass
  452.     classNm := name(if mode == BR_CMETH
  453.                       class(selClass)
  454.                     else
  455.                       selClass
  456.                     endif);
  457.     text := text + "  "
  458.             + (if isOwnClass(selClass)
  459.                  classNm
  460.                else
  461.                  "<" + classNm + ">"
  462.                endif);
  463.   endif;
  464.   setText(self,text);
  465. }!!
  466.  
  467. /* Add the method name portion of the title bar,
  468.    replacing previous method name if any.  Place
  469.    brackets around unowned method name.  The own
  470.    parameter is true if we own the method.
  471.  */
  472. Def setTitleMethod(self methodName own | text idx methText)
  473. {
  474.   text := getText(self);
  475.   idx := indexOf(text,':',0) cor size(text);
  476.   methText := ":" + if own
  477.                       methodName
  478.                     else
  479.                       "<" + methodName + ">"
  480.                     endif;
  481.   setText(self,replace(text,methText,0,size(methText),
  482.                        idx,size(text)));
  483. }!!
  484.  
  485. /* See if the user wants to overwrite class init code.
  486.  
  487.    swh modified to support extended source files
  488.  */
  489. Def saveClassInit(self | rFile, wFile, txt)
  490. { if (new(ErrorBox, self, loadString(384), loadString(383), 1) = IDOK) cand
  491.  
  492. /* mod to support extended source files */
  493.      (rFile := openClass(ExtSourceFiler, selClass))
  494.     replaceClassInit(rFile, txt := workText(ew));
  495. /* end mod */
  496.  
  497.     makeDirty(self);
  498.     initClassEdit(self);
  499.   endif;
  500. }!!
  501.  
  502. /* Load the class init code into Browser's edit
  503.   window.
  504.   
  505.   swh rewritten to support extended source files
  506.  */
  507. Def loadClassInit(self | rFile text)
  508. {
  509.   if doDirtyWork(self) cand (rFile := openClass(ExtSourceFiler, selClass))
  510.     loadMethods(self); /* Reload the method list box with no selection */
  511.     text := readClassInit(rFile);
  512.     setTitleMethod(self,"Class Init",text cand ownsLast(rFile));
  513.     if size(text) = 0
  514.       add(text, "/* "+name(selClass)+" Class Initialization Code */");
  515.     endif;
  516.     setWorkText(ew, text);
  517.     repaint(ew);
  518.   endif;
  519. }!!
  520.  
  521. /* Remove the selected method from the selected class.
  522.  
  523.    swh modified to support extended source files
  524.  */
  525. Def delSelMethod(self | cls method rFile wFile fName selIdx)
  526. {...
  527.   initCache();
  528.   
  529. /* mod to support extended source files */
  530.   if rFile := openClass(ExtSourceFiler, selClass)
  531.     showWaitCurs();
  532.     if removeMethod(rFile, nil, method, mode)
  533.       makeDirty(self);
  534.     endif;
  535.     showOldCurs();
  536. /* end mod */
  537.  
  538.   endif;
  539.   loadMethods(self);
  540. ...
  541. }!!
  542.  
  543. /* Load and return the text for the selected method.
  544.   If the source code for the selected method isn't
  545.   found, return nil.
  546.   
  547.   swh modified to support extended source files.
  548.  */
  549. Def loadSelMethod(self | rFile)
  550. { showWaitCurs();
  551.   selMethod := getSelMethod(lb2);
  552.  
  553. /* mod to support extended source files */
  554.   rFile := openClass(ExtSourceFiler,selClass);
  555.   copyMethod(ew,loadMethText(rFile,selMethod,mode) cor "");
  556.   setTitleMethod(self,selMethod,ownsLast(rFile));
  557. /* end mod */
  558.  
  559.   enableMenuItem(self, BR_DELME);
  560.   repaint(ew);
  561.   setFocus(ew);
  562.   showOldCurs();
  563. }!!
  564.  
  565. -----------------------------------------------------------------
  566.  
  567. /* CLASSDIA.CLX - Actor development extensions
  568.  *
  569.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  570.  */!!
  571. now(class(ClassDialog))!!
  572.  
  573. now(ClassDialog)!!
  574.  
  575. /* Fill dialog with class information.
  576.  
  577.    swh mod to support extended source files
  578.  */
  579. Def initDialog(self, wp, lp | ivars)
  580. { if theClass
  581.   then /* About Class */
  582.  
  583. /* mod to support extended source files
  584.  * If we don't 'own' the class, show this in
  585.  * the title bar, and don't allow user to accept
  586.  * changes to class.
  587.  */
  588.     if not(isOwnClass(theClass))
  589.       disableItem(self,IDOK);
  590.       setText(self,getText(self)+" (NOT class owner)");
  591.     endif;
  592. /* end mod */
  593.  
  594.     disableItem(self, CLASS_NAME);
  595. ...
  596. }!!
  597.  
  598. -----------------------------------------------------------------
  599.  
  600. /* CLVARDIA.CLX - Actor development extensions
  601.  *
  602.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  603.  */!!
  604. now(class(ClVarDialog))!!
  605.  
  606. now(ClVarDialog)!!
  607.  
  608. /* Initialize the dialog text.
  609.  
  610.    swh mod to support extended source files
  611.  */
  612.  
  613. Def initDialog(self, wp, lp)
  614. {
  615. /* mod to support extended source files
  616.  * If we don't 'own' the class, show this in
  617.  * the title bar, and don't allow user to
  618.  * change class vars.
  619.  */
  620.     if not(isOwnClass(selClass(parent)))
  621.       disableItem(self,IDOK);
  622.       setText(self:ancestor,getText(self:ancestor)+" (NOT class owner)");
  623.     endif;
  624. /* end mod */
  625.  
  626.  setItemText(self, 100, text);
  627.   ^1;
  628. }!!
  629.  
  630. -----------------------------------------------------------------
  631.  
  632. /* FUNCTION.CLX - Actor development extensions
  633.  *
  634.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  635.  */!!
  636. now(class(Function))!!
  637.  
  638. now(Function)!!
  639.  
  640. /* Load the source code for self from the disk.
  641.  
  642.    swh modified to support extended source files
  643.  */
  644. Def methodText(self | rFile, oFC)
  645. {
  646. /* mod to support extended source files */
  647.   if (oFC := ownerFile(self)) 
  648.      cand (rFile := openClass(ExtSourceFiler, oFC))
  649. /* end mod */
  650.  
  651.     ^loadMethText(rFile, keyAt(methods(owner(self)), self), (
  652. ...
  653. }!!
  654.  
  655. -----------------------------------------------------------------
  656.  
  657. /* METHODBR.CLX - Actor development extensions
  658.  *
  659.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  660.  */!!
  661. now(class(MethodBrowser))!!
  662.  
  663. now(MethodBrowser)!!
  664.  
  665. /* Load and return the text for the selected method.  If the source
  666.   code for the selected method isn't found, return nil.
  667.   
  668.   swh modified to support extended source files
  669.  */
  670. Def loadSelMethod(self | str, rFile, idx, clName, assoc, class)
  671. {...
  672.     mode := BR_OMETH;
  673.   endif;
  674.   
  675. /* mod to support extended source files
  676.  * Removed previous setText message.
  677.  * end mod */
  678.  
  679.   if find(str, "(prim)", idx) == idx
  680. ...
  681.   fill(lb2, class);
  682.  
  683. /* mod to support extended source files */
  684.   rFile := openClass(ExtSourceFiler,selClass);
  685.   copyMethod(ew,loadMethText(rFile, selMethod, mode));
  686.   setTitleClass(self);
  687.   setTitleMethod(self,selMethod,ownsLast(rFile));
  688. /* end mod */
  689.  
  690.   repaint(ew);
  691. ...
  692. }!!
  693.  
  694. -----------------------------------------------------------------
  695.  
  696. /* SOURCEFI.CLX - Actor development extensions
  697.  *
  698.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  699.  */!!
  700. now(class(SourceFile))!!
  701.  
  702. now(SourceFile)!!
  703.  
  704. /* Create a new class source extension file for
  705.    the class with the specified name.
  706.  */
  707. Def makeClassExtFile(self class)
  708. {
  709.   setName(self, condDelCFile(self,class));
  710.   create(self);
  711.   writeChunk(self, "now(class("+name(class)+"))");
  712.   write(self, "now("+name(class)+")"+delimiter);
  713.   close(self);
  714. }!!
  715.  
  716. /* Recompile the source code for all the classes
  717.   in the specified collection of classes.
  718.   
  719.   swh rewritten to support extended source files
  720.  */
  721. Def recompClasses(self, clColl)
  722. {
  723.   do(clColl, {using(aCl)
  724.     recompile(openClass(ExtSourceFiler,aCl));
  725.   });
  726. }!!
  727.  
  728. /* Private method.  Try to open specified class file
  729.   in the appropriate directory.
  730.   
  731.   swh rewritten to support extended source files
  732.   If the file is a .cls file, look up the directory
  733.   hierarchy for it.
  734.  */
  735. Def openClassFile(self, class | dir base)
  736. {
  737.   dir := loadString(if (name(class) in DirtyClasses)
  738.                       332 else 331 endif);
  739.   base := getFileName(class);
  740.   setName(self, dir+base);
  741.   if open(self, 0)
  742.     ^self
  743.   endif;
  744.   if base[size(base)-1] == 's'
  745.     base := "..\" + loadString(331) + base;
  746.     do(MAXSOURCENEST-1, {using(i)
  747.       if open(setName(self,base),0)
  748.         ^self;
  749.       endif;
  750.       base := "..\" + base;
  751.     });
  752.   endif;
  753.   errorBox(loadString(311), name(class)
  754.            +loadString(312)+dir+".");
  755.   ^nil;
  756. }!!
  757.  
  758. -----------------------------------------------------------------
  759.  
  760. /* STRING.CLX - Actor development extensions
  761.  *
  762.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  763.  */!!
  764. now(class(String))!!
  765.  
  766. now(String)!!
  767.  
  768. /* Open and compile the file named by self.
  769.  
  770.    swh rewritten to support hierarchical dir's.
  771.    Look first in the current directory of this
  772.    actor session, and then look progressively
  773.    up the directory hierarchy.
  774.  */
  775. Def load(self)
  776. {
  777.   showWaitCurs();
  778.   load(new(SourceFile),findPath(self) cor self);
  779.   showOldCurs();
  780. }!!
  781.  
  782. /* Find and return the 'closest' directory path
  783.    +filename where the file named by self exists
  784.  */
  785. Def findPath(self | fileNm)
  786. {
  787.   fileNm := self;
  788.   do(MAXSOURCENEST, {using(i)
  789.     if exists(File,fileNm,0)
  790.       ^fileNm;
  791.     endif;
  792.     fileNm := "..\"+fileNm;
  793.   });
  794.   ^nil;
  795. }!!
  796.  
  797. -----------------------------------------------------------------
  798.  
  799. /* SYMBOL.CLX - Actor development extensions
  800.  *
  801.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  802.  */!!
  803. now(class(Symbol))!!
  804.  
  805. now(Symbol)!!
  806.  
  807. /* Load class extension files (.clx) for the class
  808.    whose name is this symbol, but don't load the
  809.    class file (.cls).  This is useful for loading
  810.    extensions to the standard Actor classes.
  811.  */
  812. Def loadExtensions(self)
  813. {
  814.   ^loadExtensions(openClass(ExtSourceFiler,self));
  815. }!!
  816.  
  817. /* Load the class whose name is this symbol.
  818.    Loads the original class file (.cls)
  819.    followed by class extension files (.clx).
  820.  */
  821. Def load(self)
  822. {
  823.   ^load(openClass(ExtSourceFiler,self));
  824. }!!
  825.  
  826. -----------------------------------------------------------------
  827.  
  828. /* SYSTEM.CLX - Actor development extensions
  829.  *
  830.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  831.  */!!
  832. now(class(System))!!
  833.  
  834. /*  Return date & time as a string: yyyy/mm/dd hh:mm.
  835.  */
  836. Def  timeStamp(self | ds tempStr)
  837. {
  838.   ds := new(Struct, 18);
  839.   putMSB(ds, 0x2a, 4);
  840.   call(ds);
  841.   tempStr:=
  842.     asPaddedString(wordAt(ds, 8),4) + "/" + 
  843.     asPaddedString(atMSB(ds, 10),2) + "/" + 
  844.     asPaddedString(atLSB(ds,10),2);
  845.   putMSB(ds, 0x2c, 4);
  846.   call(ds); /* get system time */
  847.   ^tempStr + " " + asPaddedString(atMSB(ds, 8),2)
  848.   + ":" + asPaddedString(atLSB(ds, 8),2);
  849. }!!
  850.  
  851. /* Return the initials of the programmer for this
  852.    Actor session.
  853.  */
  854. Def  programmer(self)
  855. {
  856.   ^Programmer;
  857. }!!
  858.  
  859. now(System)!!
  860.  
  861. -----------------------------------------------------------------
  862.  
  863. /* TOOLWIND.CLX - Actor development extensions
  864.  *
  865.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  866.  */!!
  867. now(class(ToolWindow))!!
  868.  
  869. /* Used by the system to initialize the DirtyClasses
  870.   Set backup file.  DirtyClasses is assumed to be
  871.   empty on entry.  For each class found in the backup
  872.   file, ask the user whether to re-load the dirty
  873.   class file or use the old class file. 
  874.  
  875.   swh modified to support extended source files.
  876.   swh modified to support unique dirty class file
  877.   names between images.
  878.  */
  879. Def loadDirty(self | dName)
  880. {
  881. /* mod for unique dirty file name - base the dirty
  882.  * file name on the image name.
  883.  */
  884.   setName($DFile,subString(imageName(TheApp),0,
  885.                  indexOf(imageName(TheApp),'.',0))
  886.                  +".drt");
  887. /* end mod */
  888.  
  889.  if open($DFile, 0)
  890.   then
  891. ...
  892.   if size(DirtyClasses) > 0
  893.   then do(copy(DirtyClasses),
  894.     {using(clName)
  895.  
  896. /* mod for extended source file support - if the dirty
  897.  * class exists in the system, let it tell us its file
  898.  * name (.cls or .clx), otherwise the class was created
  899.  * since the last snapshot, so it should be a .cls file.
  900.  */
  901.       dName := loadString(332) + subString(clName,0,8)
  902.                + if not(Classes[clName])
  903.                     cor isOwnClass(Classes[clName])
  904.                   ".cls" else ".clx" endif;
  905. /* end mod */
  906.  
  907.       dName := loadString(332) + subString(clName,0,8) + ".cls";
  908. ...
  909. }!!
  910.  
  911. now(ToolWindow)!!
  912.  
  913. /* Insert/overwrite a time stamp as the first line of
  914.    the method text.
  915.  */
  916. Def stampMethText(self text fSym mode | stampHead)
  917. {
  918.   stampHead := "/*"+StampText;
  919.   
  920. /* if method doesn't already have a stamp, insert
  921.  * a line for it.
  922.  */
  923.   if left(text[0],size(stampHead),' ') <> stampHead
  924.     insert(text,"",0);
  925.   endif;
  926.   
  927. /* construct the time stamp. */
  928.   text[0] := stampHead+" "+timeStamp(System)+" "
  929.              +programmer(System)+" "+name(selClass)
  930.              +if mode == BR_CMETH 
  931.                 "(Class)" else "" endif
  932.              +":"+fSym+" */";
  933. }!!
  934.  
  935. /* Save the new text for current method into the source
  936.   file. The first argument, text, is the method text.  The
  937.   second, fSym, is the symbol with the name of the method,
  938.   e.g. #print.  The new or revised method text ends up in a
  939.   class source file in WORK.  Also, write the text to the
  940.   change log.
  941.   
  942.   swh modified to support extended source files
  943.   swh modified to support automatic time stamping
  944.  */
  945. Def saveMethText(self, text, fSym | textEnd, nowCl, rFile, wFile)
  946. {...
  947.     changeLog(ew, "now(" + nowCl + ")" + Chunk +
  948.       subText(text, 0, 0, textEnd, size(text[textEnd])));
  949.       
  950. /* mod for automatic time stamps
  951.  * place time stamp in method text.
  952.  */
  953.     if text
  954.       stampMethText(self,text,fSym,mode);
  955.     endif;
  956. /* end mod */
  957.  
  958. /* mod to support extended source files */
  959.     saveMethText(openClass(ExtSourceFiler,selClass),
  960.                  text, fSym, mode);
  961. /* end mod */
  962.  
  963.     makeDirty(self);
  964.   endif;
  965.   ^fSym;
  966. }!!
  967.  
  968. /* ToolWindow class initialization 
  969.    Rewritten to override ToolWindow.cls class
  970.    initialization to support unique dirty file
  971.    names between images - base the dirty file
  972.    name on the image name.
  973.  */
  974. $DFile := setName(new(TextFile),
  975.                   subString(imageName(TheApp),0,
  976.                      indexOf(imageName(TheApp),'.',0))
  977.                   +".drt");
  978.  
  979. -----------------------------------------------------------------
  980.  
  981. /* WORKEDIT.CLX - Actor development extensions
  982.  *
  983.  * Copyright(C) 1991 Steve Hatchett.  All rights reserved.
  984.  */!!
  985. now(class(WorkEdit))!!
  986.  
  987. now(WorkEdit)!!
  988.  
  989. /* Write the given string to the Change Log File.
  990.  
  991.   swh modified to support unique change log file
  992.   names between images.
  993.  */
  994. Def changeLog(self, aStr | file)
  995. { file := new(File);
  996.  
  997. /* mod for unique change log name - base the change
  998.  * log name on the image name.
  999.  */
  1000.   setName(file,subString(imageName(TheApp),0,
  1001.                  indexOf(imageName(TheApp),'.',0))
  1002.                  +".log");
  1003. /* end mod */
  1004.  
  1005.   open(file,1) cor create(file);
  1006.   lseek(file, 0, 2);
  1007.   write(file, aStr + Chunk);
  1008.   close(file);
  1009. }!!
  1010. Set backup file.  DirtyClasses is assumed to be
  1011.   empty on entry.  For each class found in the
  1012.